<?php

namespace app\pc\controller;
use app\base\controller\Base;
use think\Request;
use think\Cache;
use think\Config;
use think\Session;

/**
 * Class Pcsite
 * @package app\admin\controller  PCsite配置
 */
class Pcsite extends Base
{
    public  $model;

    public function __construct()
    {
   $this->model = model("PcSite");
        parent::__construct();
    }


    /**
     *  pC具体设置
     *
     * @return \think\Response
     */
    public function index()
    {//

        $where = [];
        //时间的处理
        $where['p.position_key'] = $this->position_key2;


        $res =   $this->model->AdminPageNoAgent($where);
        if(empty($res)){
            return failJson("暂无记录");
        }
       $result = [];
        foreach($res['res'] as $k=>$v){
            $result[$v['key']] = $v;
        }
        $res['res'] = $result;
        return   resJson(1,$this->ecLang("query"),$res['res'],$res['pageInfo']);
    }


    /**
     *  获取组key
     */
    public function save(){
        $where = [];
        //时间的处理
        if(!is_array($this->position_key3)){
            return failJson("位置key 必须为数组");
        }
        $where['p.position_key'] = ['in',$this->position_key3];
        $res =   $this->model->AdminPageNoAgent($where,1000);
        if(empty($res)){
            return failJson("暂无记录");
        }

        $result = [];
        foreach($res as $k=>$v){
                if(is_array($v)&&!empty($v)){
                        foreach($v as $kk=>$vv){
                            if(!empty($vv['position_key'])){

                                $result[$vv['position_key']][$vv['key']] =$vv;
                            }

                        }
                }
        }

        $res['res']  = $result;

        return   resJson(1,$this->ecLang("query"),$res['res'],$res['pageInfo']);
    }





}
